INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

FILE(GLOB TILE_EDIT_SRC *.cpp *.h)
FILE(GLOB PIC_SRC pic/*.c pic/*.cpp)
SET(TILE_EDIT_HDR items_edit_dlg.h tile_browser_dlg.h tile_edit_dlg.h tile_rotation_dlg.h tiles_model.h tile_widget.h)
SET(TILE_EDIT_UIS tile_widget_qt.ui tile_rotation_qt.ui tile_edit_qt.ui tile_browser_qt.ui items_edit_qt.ui)
SET(TILE_EDIT_RCS tile_edit_qt.qrc)

IF(WITH_QT)
  INCLUDE_DIRECTORIES(${QT_INCLUDES})
  INCLUDE(${QT_USE_FILE})

  QT4_ADD_RESOURCES(TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS})
  QT4_WRAP_UI(TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS})
  QT4_WRAP_CPP(TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR})

  ADD_DEFINITIONS(${QT_DEFINITIONS})
ELSEIF(WITH_QT5)
  QT5_ADD_RESOURCES(TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS})
  QT5_WRAP_UI(TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS})
  QT5_WRAP_CPP(TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR})
ENDIF()


SOURCE_GROUP(QtResources FILES ${TILE_EDIT_UIS} ${TILE_EDIT_RCS})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${TILE_EDIT_UI_HDRS})
SOURCE_GROUP(QtGeneratedMocSrc FILES ${TILE_EDIT_MOC_SRCS})

ADD_EXECUTABLE(tile_edit_qt WIN32 ${TILE_EDIT_SRC} ${TILE_EDIT_MOC_SRCS} ${TILE_EDIT_RC_SRCS} ${TILE_EDIT_UI_HDRS})

TARGET_LINK_LIBRARIES(tile_edit_qt ${QT_LIBRARIES} nelmisc nel3d)
NL_DEFAULT_PROPS(tile_edit_qt "NeL, Tools, 3D: Qt Tile Editor")
NL_ADD_RUNTIME_FLAGS(tile_edit_qt)

IF(WITH_PCH)
  ADD_NATIVE_PRECOMPILED_HEADER(tile_edit_qt ${CMAKE_CURRENT_SOURCE_DIR}/common.h ${CMAKE_CURRENT_SOURCE_DIR}/common.cpp)
ENDIF()

INSTALL(TARGETS tile_edit_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d)

